<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看运单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">

</head>
<body  >
<div class="layui-container">


    <form class="layui-form">
        <div class="layui-row">
            <div class="layui-col-md12">

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>运单信息</legend>


                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 90px"><span style="color: red;">*</span>运单号 </label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="ydh"  required lay-verify="required" placeholder="请输入"  class="layui-input" id="ydh" >

                            <input   type="hidden" name="ydid"  >
                            <input   type="hidden" name="sfcz" value="1"  >
                            <input   type="hidden" name="sfscdd" value="1"  >
                        </div>


                        <label class="layui-form-label" style="width: 100px"><span style="color: red;">*</span>运单日期 </label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="ydrq"  required lay-verify="required" placeholder="请输入"  class="layui-input"  >
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 73px" ><span style="color: red;">*</span>运单状态</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <select name="ydzt" required lay-verify="required" id="ydzt"  >
                                    <option value=""></option>
                                    <option value="待调度">待调度</option>
                                    <option value="待发车">待发车</option>
                                    <option value="已发车">已发车</option>
                                    <option value="已回车">已回车</option>
                                    <option value="审核中">审核中</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:69px"><span style="color: red;">*</span>客户简称</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="khjc" required lay-verify="required" placeholder="请输入"  class="layui-input">
                                <input type="hidden" name="khid"  >
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">

                        <label class="layui-form-label"><span style="color: red;">*</span>区域名称</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="qymc"  required lay-verify="required" placeholder="请输入"  class="layui-input"  >
                            <input type="hidden" name="qyid"  >
                        </div>

                        <label class="layui-form-label" style="width: 99px"><span style="color: red;">*</span>线路名称</label>
                        <div class="layui-input-inline" style="width: 423px;">
                            <input   type="text" name="xlmc"  required lay-verify="required" placeholder="请输入"  class="layui-input"  >
                            <input type="hidden" name="xlid"  >
                        </div>




                        <label class="layui-form-label" style="width: 75px">货物</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="huowu"      class="layui-input" id="huowu" >
                        </div>

                    </div>
                    <div class="layui-form-item">




                        <div class="layui-inline">
                            <label class="layui-form-label" >货物数量</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="hwsl"      class="layui-input" id="hwsl"  >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 85px">运费</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="yunfei"     class="layui-input" id="yunfei" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 61px">公里数</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="gls" class="layui-input" id="gls" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px">油单价</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="ydj" class="layui-input" id="ydj" >
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label" >车牌号</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="cph"      class="layui-input" id="cph"  >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 85px">车辆类型</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="cllx"     class="layui-input" id="cllx" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 61px">驾驶员</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="jsy" class="layui-input" id="jsy" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px">驾驶员手机</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="ydj" class="layui-input" id="jsysj" >
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">


                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 90px">百公里油耗</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="bglyh"     class="layui-input" id="bglyh" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 85px">理论充油金额</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="llcyje" class="layui-input" id="llcyje" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 62px">发车日期</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="fcrq" class="layui-input" id="fcrq" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px">类型</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="leixing" class="layui-input" id="leixing" >
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 600px">注：理论充油金额=油单价（元/L）×百公里油耗（L/百公里）×公里数（公里）</label>
                    </div>
                    <!--<div class="layui-form-item">-->
                        <!--<div class="layui-input-block" style="position: relative;left: 370px">-->

                            <!--<div class="layui-btn layui-btn-normal"  id="modiInfo"  >修改信息</div>-->
                            <!--<button id="modiSub" class="layui-btn layui-btn-normal layui-btn-disabled" disabled lay-submit lay-filter="update" >立即提交</button>-->
                        <!--</div>-->
                    <!--</div>-->
                </fieldset>
            </div>
        </div>
    </form>
    <form class="layui-form">
        <div class="layui-row">
            <div class="layui-col-md12">

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>回车登记</legend>


                    <div class="layui-form-item">



                        <label class="layui-form-label" style=""> 回车日期 </label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="hcrq"    placeholder="请输入"  class="layui-input" id="hcrq" >
                            <input   type="hidden" name="ydid"  >
                            <input   type="hidden" name="ydh"  >
                        </div>

                        <label class="layui-form-label" style="width: 90px" >收货方 </label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="shf"    placeholder="请输入"  class="layui-input"  id="shf">
                        </div>
                        <label class="layui-form-label" style="width: 75px" >回单号</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="hdh"    placeholder="请输入"  class="layui-input"  id="hdh">
                        </div>

                    </div>
                    <div class="layui-form-item">

                        <label class="layui-form-label">实发量</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="sfl"    placeholder="请输入"  class="layui-input"  id="sfl">
                        </div>

                        <label class="layui-form-label"  >实收量</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="hcssl"   placeholder="请输入"  class="layui-input" id="hcssl" >

                        </div>

                        <label class="layui-form-label" style="width: 75px">实际运费</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="sjyf"   placeholder="请输入"   class="layui-input" id="sjyf" >
                        </div>

                        <label class="layui-form-label" style="width: 75px">损耗金额</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input   type="text" name="shje"   placeholder="请输入"   class="layui-input" id="shje" >
                        </div>

                    </div>
                    <div class="layui-form-item">




                        <div class="layui-inline">
                            <label class="layui-form-label" >代垫费</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="ddf"      class="layui-input"  placeholder="请输入" id="ddf">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 78px">实际公里数</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="sjgls"     class="layui-input" placeholder="请输入"  id="sjgls">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 61px">应收金额</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="ysje" class="layui-input" placeholder="请输入" id="ysje" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 60px">实收金额</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input type="text" name="ssje" class="layui-input" placeholder="请输入"  id="ssje">
                            </div>
                        </div>
                    </div>



                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label" >回单照片</label>
                            <input type="hidden" name="hdzp" autocomplete="off" class="layui-input" id="hdzp">

                            <button type="button" class="layui-btn layui-btn-normal  "   id="hdzpBtn" style="display: none" >上传文件</button>
                            <button type="button" class="layui-btn layui-btn-normal  "   id="lookhdzpBtn" style="display: none">查看文件</button>

                            <button type="button" class="layui-btn layui-btn-normal  "  style="display: none" id="delhdzpBtn">删除文件</button>

                        </div>

                    </div>
                    <div class="layui-form-item"  >

                        <div class="layui-inline ">
                            <label class="layui-form-label" style="width: 90px" >是否准点</label>
                            <div class="layui-input-inline" style="width: 95px;">
                                <select name="sfzd"  id="sfzd"  lay-filter="sfzd" >
                                    <option value="是">是</option>
                                    <option value="否">否</option>
                                </select>

                            </div>
                        </div>

                    </div>
                    <div class="layui-form-item"   id="latePhoto" >

                        <div class="layui-inline">
                            <label class="layui-form-label" >晚点照片</label>
                            <input type="hidden" name="wdzp" autocomplete="off" class="layui-input" id="wdzp">

                            <button type="button" class="layui-btn layui-btn-normal  "   id="wdzpBtn" style="display: none"  >上传文件</button>
                            <button type="button" class="layui-btn layui-btn-normal  "   id="lookwdzpBtn" style="display: none">查看文件</button>

                            <button type="button" class="layui-btn layui-btn-normal  "  style="display: none" id="delwdzpBtn">删除文件</button>

                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 145px">晚点原因</label>
                            <div class="layui-input-inline" style="width: 430px;">
                                <input type="text" name="wdyy" class="layui-input" placeholder="请输入"  id="wdyy">
                            </div>

                        </div>

                    </div>


                </fieldset>
            </div>


        </div>

        <button id="modiSub" class="layui-btn layui-btn-normal layui-btn-disabled" disabled lay-submit lay-filter="update" style="width: 10%; position: absolute;left: 45%"  >立即提交</button>
    </form>
</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/tools.js"></script>
<script>
    layui.use(['table','form','layer','laydate','upload'],function () {

        var $ = layui.$;
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;
        $(".layui-input").addClass("layui-disabled");
        $(".layui-input").attr("disabled",true);
        $("select").attr("disabled","disabled");
        //准点判断
        form.on("select(sfzd)",function (data) {
            if(data.value == "否"){
                $("#latePhoto").show();
            }else {
                $("#latePhoto").hide();
            }

        })
        if($("#sfzd").val() == "否"){
            $("#latePhoto").show();
        }else {
            $("#latePhoto").hide();
        }

        //校验
        judgments($,["yunfei","gls","ydj","bglyh","llcyje","sfl","hcssl","sjyf","shje","ddf","sjgls","usje","ssje","ysje","hwsl"],/^([1-9]\d*|0)(\.\d{1,2})?$/,"请输入整数或小数");
        judgment($,'jsysj',/^\d{11}$/,"请输入正确的手机号码");
        //判断是不是已经回车
        if($("#ydzt").val()=="已回车" || $("#ydzt").val()=="审核中"){

        }else {
            $("#shf,#sfl,#hcssl,#sjyf,#sjyf,#shje,#ddf,#sjgls,#ysje,#ssje,#sfzd,#wdyy,#hdh").attr("disabled",false);
            $("#shf,#sfl,#hcssl,#sjyf,#sjyf,#shje,#ddf,#sjgls,#ysje,#ssje,#sfzd,#wdyy,#hdh").removeClass("layui-disabled");
            $("#modiSub").removeClass("layui-btn-disabled");
            $("#modiSub").attr("disabled",false);
        }
//重新渲染 select
        form.render('select');

        laydate.render({
            elem: '#hcrq' //指定元素
            ,theme:'#0099FF'
            ,value: getFormatDate()
            ,type: 'date'
            ,format:'yyyy-MM-dd'
        });



        //上传文件
        if($("#ydzt").val()=="已回车" || $("#ydzt").val()=="审核中"){
            checkFileB($,$("#hdzp").val(),"hdzp",false,false);
            checkFileB($,$("#wdzp").val(),"wdzp",false,false);
        }else {
            checkFileB($,$("#hdzp").val(),"hdzp",true,true);
            checkFileB($,$("#wdzp").val(),"wdzp",true,true);
        }

        console.log($("#ydzt").val());

        uploadOneFile(upload,$,layer,"backcar",$("#ydh").val(),"hdzp");
        uploadOneFile(upload,$,layer,"backcar",$("#ydh").val(),"wdzp");

        delFile($,layer,"hdzp");
        delFile($,layer,"wdzp");
        lookFile($,layer,"hdzp");
        lookFile($,layer,"wdzp");

//提交
        form.on('submit(update)', function(data){
            $("input").css("border","");
            console.log(JSON.stringify(data.field) );
            $.ajax({
                url: contextPath+"/register",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    console.log(res);
                    updateSuccess($,layer,res)
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    });

</script>
</body>
</html>